//
//  ViewController.m
//  AppleSignIn
//
//  Created by xingshuai on 2021/8/23.
//

#import "ViewController.h"

#import "XSAppleManager.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = UIColor.orangeColor;
    
    [self configUI];
}

-(void)configUI{
    if (@available(iOS 13.0, *)) {
        ASAuthorizationAppleIDButton *authorizationButton = [[ASAuthorizationAppleIDButton alloc]initWithAuthorizationButtonType:ASAuthorizationAppleIDButtonTypeSignIn authorizationButtonStyle:ASAuthorizationAppleIDButtonStyleWhite];
        [authorizationButton addTarget:self action:@selector(clickBtn) forControlEvents:(UIControlEventTouchUpInside)];
        authorizationButton.center = self.view.center;
        [self.view addSubview:authorizationButton];
    } else {
        // Fallback on earlier versions
    }
}

-(void)clickBtn API_AVAILABLE(ios(13.0)) {
    // 封装Sign In with Apple
    [[XSAppleManager sharedManager] handleAuthorizationAppleIDButtonLogin];
}


@end
